﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Genesis
{
    public partial class frmPlaylist : Form
    {
        public frmPlaylist()
        {
            InitializeComponent();
        }

        private void frmPlaylist_Load(object sender, EventArgs e)
        {
            if (Library.RenamePlaylist)
            {
                this.Text = "Rename Playlist";
                txtName.Text = Library.Playlists[Library.RenamePlaylistID].Name;
                cmdCreate.Text = "Rename";
            }
        }
        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
        private void cmdCreate_Click(object sender, EventArgs e)
        {
            if (Library.RenamePlaylist)
            {
                Library.Playlists[Library.RenamePlaylistID].Name = txtName.Text;
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                Library.NewPlaylist(txtName.Text, null);
                this.DialogResult = DialogResult.OK;
            }
        }
        private void txtName_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                cmdCreate_Click(null, null);
                e.Handled = true;
            }
        }
    }
}
